package com.cskaoyan.gateway.controller.shopping;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.shopping.NavigationService;
import com.mall.shopping.constants.ShoppingRetCode;
import com.mall.shopping.dto.PanelContentResponse;
import com.mall.user.annotation.Anoymous;
import io.swagger.annotations.Api;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



@RestController
@RequestMapping("/shopping")
@Api(tags = "NavigationController", description = "导航栏控制层")
public class NavigationController {

    @Reference(timeout = 3000, check = false, interfaceClass = NavigationService.class)
    NavigationService navigationService;


    @Anoymous
    @GetMapping("/navigation")
    public ResponseData getNavigation(){
        PanelContentResponse response = navigationService.getNavigation();
        if(response.getCode().equals(ShoppingRetCode.SUCCESS.getCode())) {
            ResponseUtil responseUtil = new ResponseUtil();
            ResponseData responseData = responseUtil.setData(response.getPanelContentDtoList());
            return responseData;
        } else  {
            ResponseUtil responseUtil = new ResponseUtil();
            ResponseData responseData = responseUtil.setErrorMsg(response.getMsg());
            return responseData;
        }
    }

}
